﻿using System;
using System.Web.UI;
using BBCode;
using BBCode.Collections;
using BBCode.Nodes;
using BBCodeTestWebsite.SampleCode;

public partial class _Default : Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        var parser = new Parser(new TagCollection
                                    {
                                        SmileyTagFactory.Smile
                                    },
                                new TagCollection
                                    {
                                        BBCodeTagFactory.Bold,
                                        BBCodeTagFactory.Italic,
                                        BBCodeTagFactory.Underline,
                                        BBCodeTagFactory.Strike,
                                        BBCodeTagFactory.Code,
                                        BBCodeTagFactory.H1,
                                        BBCodeTagFactory.H2,
                                        BBCodeTagFactory.H3,
                                        BBCodeTagFactory.Preformated,
                                        BBCodeTagFactory.Quote,
                                        BBCodeTagFactory.Align,
                                        BBCodeTagFactory.Color,
                                        BBCodeTagFactory.Size,
                                        BBCodeTagFactory.Url,
                                        BBCodeTagFactory.List,
                                        BBCodeTagFactory.Youtube,
                                        BBCodeTagFactory.HorizontalRuler,
                                        BBCodeTagFactory.Image,
                                        BBCodeTagFactory.Thumbnail
                                    });

        ParseResult result = parser.Parse(txtInput.Text);

        htmlResults.InnerHtml = result.Print();
        txtResults.Text = Server.HtmlEncode(htmlResults.InnerHtml);

        INode node = result.GetFirst(BBCodeTagFactory.Bold);
        node = result.GetFirst(BBCodeTagFactory.Italic);
    }
}